# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        潘炎珍  
# Name:         demo07
# Description:
# Author:       98745
# Date:         2019/3/3
#-------------------------------------------------------------------------------

class my():
    def m1(self):
        print('m1')
    def d(self):
        print('data')
m=my()
if hasattr(m,'m1'):
    m.m1()
else:
    print('m1方法不存在')
if hasattr(m,'m2'):
    m.m2()
else:
    print('m2方法不存在')
met=getattr(m,'m2',m.d)
met()

def m2():
    print('动态添加m2')
setattr(m,'m2',m2)
m.m2()